<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>福利城堡-活动详细页-资料下载</title>
<link href="../c/base.css" rel="stylesheet" type="text/css">
<link href="../c/toefl.css" rel="stylesheet" type="text/css">
<link href="../c/bootstrap.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript"
	src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="../layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(function() {
		$(".classInfo_menu>ul>li>a").click(function(e) {
			if (e.currentTarget.id == "detail") {
				$(".classInfo_menu>ul>li").removeClass("on");
				$(e.currentTarget).parent().addClass("on");
				$(".castleInfoList").hide();
				$("#commentContent").hide();
				$(".inventDetail").show();

			} else if (e.currentTarget.id == "download") {
				$(".classInfo_menu>ul>li").removeClass("on");
				$(e.currentTarget).parent().addClass("on");
				$("#commentContent").hide();
				$(".inventDetail").hide();
				$(".castleInfoList").show();

			} else if (e.currentTarget.id == "comment") {
				$(".classInfo_menu>ul>li").removeClass("on");
				$(e.currentTarget).parent().addClass("on");
				$(".inventDetail").hide();
				$(".castleInfoList").hide();
				$("#commentContent").show();
			}
		})

		var flag = $("#flag").val();
		if (flag == 1) {
			$("#comment").click();
		}
	})

	function searchCastle(mall_type) {
		$("#mall_type").attr("value", mall_type);
		$("#castleForm").submit();
	}

	function payLimit(castle_id, status) {
		var loginMessage = $("#loginMessage").val();
		if (loginMessage == null || loginMessage == '') {
			layer.confirm('请先登录，再加入！！', {title:'提示'}, function(index){
				window.parent.location = "toLogin";
				layer.close(index);
			}, function(){
				layer.close();
			});

		} else if (loginMessage == 'teacher') {
			layer.confirm('只有用户才可以加入，请使用用户账号登录！！', {title:'提示'}, function(index){
				window.parent.location = "toLogin";
				layer.close(index);
			}, function(){
				layer.close();
			});
		} else if(status != '0') {
			layer.alert('课程已经结束报名了，看看别的吧！', function(index){
				layer.close(index);
			});
		} else {
			$.ajax({
				url : 'isBuy',
				type : 'post',
				dateType : 'json',
				data : {
					castle_id : castle_id
				},
				success : function(result) {
					if (result) {
						layer.alert('你已经购买过这个课程，再看别的吧！', function(index) {
							layer.close(index);
						});
					} else {
						window.location = "toStepOne?castle_id=" + castle_id;
					}
				}
			})			
		}
	}

	function changeColor(castle_id) {
		var loginMessage = $("#loginMessage").val();
		if (loginMessage == null || loginMessage == '') {
			layer.confirm('请先登录，再点赞！！', {
				title : '提示'
			}, function(index) {
				window.parent.location = "toLogin";
				layer.close(index);
			}, function() {
				layer.close();
			});

		} else if (loginMessage == 'teacher') {
			layer.confirm('只有用户才可以点赞，请使用用户账号登录！！', {
				title : '提示'
			}, function(index) {
				window.parent.location = "toLogin";
				layer.close(index);
			}, function() {
				layer.close();
			});
		} else {
			var heart = $("#heart");
			var flag;
			if (heart.css("color") == "rgb(128, 128, 128)") {
				flag = 1;
				heart.css("color", "#E6312A");
			} else {
				flag = 2;
				heart.css("color", "#808080");
			}
			$.ajax({
				url : 'addOrDelCollect',
				type : 'post',
				data : {
					castle_id : castle_id,
					flag : flag
				},

				success : function(result) {
					$("#collectnum").html(result);
				}
			})
		}
	}

	function addComment() {
		var loginMessage = $("#loginMessage").val();
		if (loginMessage == null || loginMessage == '') {
			layer.confirm('请先登录，再评论！！', {
				title : '提示'
			}, function(index) {
				window.parent.location = "toLogin";
				layer.close(index);
			}, function() {
				layer.close();
			});
		} else {
			var coment_desc = $("#coment_desc").val();
			if (coment_desc == '') {
				layer.alert('评论内容不能为空！', function(index) {
					layer.close(index);
				})
				return false;
			} else {
				$("#commentform").submit();
				return true;
			}

		}
	}

	function editComment(coment_id) {
		var desc = document.getElementById("desc_" + coment_id);
		desc.readOnly = false;
		$("#editAndDel" + coment_id).css("display", "none");
		$("#commit" + coment_id).css("display", "");
	}

	function editCommit(coment_id) {
		var desc = $("#desc_" + coment_id).val();
		if (desc == '') {
			layer.alert('修改内容不能为空！', function(index) {
				layer.close(index);
			})
			return false;
		} else {
			$("#editform_" + coment_id).submit();
			return true;
		}

	}
	
	function phrase(teacher_id, castle_id){
		var isPhrase = $("#isPhrase_" + castle_id);
		var loginMessage = $("#loginMessage").val();
		var flag;
		if(isPhrase.text() == '赞'){
			flag = 1;
		}else if (isPhrase.text() == '取消'){
			flag = 2;
		}
		if (loginMessage == null || loginMessage == '') {
			layer.confirm('请先登录，再点赞！！', {
				title : '提示'
			}, function(index) {
				window.parent.location = "toLogin";
				layer.close(index);
			}, function() {
				layer.close();
			});

		} else if (loginMessage == 'teacher') {
			layer.confirm('只有用户才可以点赞，请使用用户账号登录！！', {
				title : '提示'
			}, function(index) {
				window.parent.location = "toLogin";
				layer.close(index);
			}, function() {
				layer.close();
			});
		} else {
			$.ajax({
				url : 'addOrDelPhrase',
				type : 'post',
				dataType : 'json',
				data : {
					teacher_id : teacher_id,
					flag : flag
				},
				success : function(result){
					if(flag == 1){
						isPhrase.html('取消');
					}else if(flag == 2){
						isPhrase.html('赞');
					}
					$("#zanNum").html('（' + result + '）');
				}
				
			})
		}
		
	}
</script>

</head>

<body>
	<input type="hidden" name="loginMessage" id="loginMessage"
		th:value="${session.loginMessage}">
	<input type="hidden" name="flag" id="flag" th:value="${flag}">
	<!-- 查询 -->
	<form action="toCastle" method="post" id="castleForm">
		<input type="hidden" name="mall_type" id="mall_type">
	</form>
	<div class="openMenu">
		<div class="doc1180">
			<ul class="fn-clear" style="padding-left: 220px;">
				<li th:each="mallType:${mallTypes}"
					th:class="${castle.mall_type == mallType.type_id} ? 'openMenuOn' : ''"
					style="float: left;"><a href="###"
					th:onclick="searchCastle([[${mallType.type_id}]])">[[${mallType.type_name}]]</a>
				</li>
			</ul>
		</div>
	</div>
	<div class="doc1180">
		<div class="crumbs_patch">
			<a href="###" th:onclick="searchCastle([[${castle.mall_type}]])">[[${castle.mallType.type_name}]]</a>&gt;&nbsp;<span>[[${castle.class_title}]]</span>
		</div>
		<div class="castleInfo">
			<dl>
				<dt>
					<a href="###"><img th:src="${castle.img_url}"></a>
				</dt>
				<dd th:object="${castle}">
					<div class="castleInfo_title">[[*{class_title}]]</div>
					<div class="castleTime">
						上课时间：<span>[[*{#dates.format(start_date, 'yyyy-MM-dd')}]]</span>到<span>[[*{#dates.format(end_date,
							'yyyy-MM-dd')}]]</span>&nbsp;&nbsp;&nbsp;&nbsp; 每周： <span
							style="color: green;">[[*{castle_cycle}]]</span>&nbsp;的&nbsp;<span
							style="color: red;">[[*{#dates.format(start_time,
							'HH:mm')}]]-[[*{#dates.format(end_time, 'HH:mm')}]]</span>上课
					</div>
					<div class="flcb_cardTech">
						<span class="first">主讲老师：</span> <span class="teacherPic"><img
							th:src="*{teacher.img_url}"></span> <span class="name">[[*{teacher.user_name}]]</span>
						<span class="zan"><a href="###"
								th:onclick="phrase([[*{teacher_id}]], [[*{castle_id}]])"><img
									src="../i/icon_zan14x14.jpg"></a></span>
							<div th:switch="*{teacher_id}"
								th:if="${session.loginMessage == 'user'}">
								<div th:each="phrase : ${teacherPhrases}">
									<span class="zan" th:case="${phrase.teacher_id}"
										th:id="'isPhrase_' + *{castle_id}" style="width:40px" >取消</span>
								</div>
								<span class="zan" th:case="*"
									th:id="'isPhrase_' + *{castle_id}" style="width:40px">赞</span>
							</div>
							<span class="zan"
								th:if="${session.loginMessage == 'teacher' || session.loginMessage == null}"
								th:id="'isPhrase_' + *{castle_id}">赞</span><span
								class="zanNum" id="zanNum">（[[*{teacher.phrase_num}]]）</span>
					</div>
					<div class="castleInfo_time">活动地点：[[*{castle_address}]]</div>
					<div class="castleInfo_time">
						<span class="castleInfo_Cy"><b>[[*{signup_num}]]</b>人参与</span> <span
							class="castleInfo_Cy"><b id="collectnum">[[*{collect_num}]]</b>人关注</span>
						<span class="castleInfo_Rs">RMB：<b>[[*{castle_pay}]]</b></span> <span
							id="heart" class="glyphicon glyphicon-heart"
							style="font-size: 25px;"
							th:styleappend="${collect == null} ? 'color:#808080' : 'color:#E6312A'"
							aria-hidden="true" th:onclick="changeColor([[*{castle_id}]])"></span>
					</div>

					<div class="fn-clear marginB15">
						<a href="###" class="classInfo_ljbm"
							th:onclick="payLimit([[*{castle_id}]], [[*{status}]])">立即报名</a> <a href="###"
							class="classInfo_join">加入该活动群</a>
					</div>
					<div class="classInfo_icon fn-clear">
						<ul>
							<li><a href="###" class="classInfo_iconWx">微信</a></li>
							<li><a href="###" class="classInfo_iconWb">微博</a></li>
							<li><a href="###" class="classInfo_iconKj">空间</a></li>
							<li><a href="###" class="classInfo_iconQQ">QQ</a></li>
							<li><a href="###" class="classInfo_iconrr">人人</a></li>
						</ul>
					</div>
				</dd>
			</dl>
		</div>
		<div class="classInfo_main">
			<div class="classInfo_mainL">
				<div class="classInfo_menu fn-clear">
					<ul>
						<li class="on"><a href="###" id="detail">活动详情</a></li>
						<li><a href="###" id="download">资料下载</a></li>
						<li><a href="###" id="comment">考生评价</a></li>
					</ul>
				</div>

				<div class="castleInfoList" style="display: none;">
					<ul>
						<li th:each="castleAtta:${castleAttas}"><a class="zlxz"
							th:href="@{/downloadAtta(attachment_id = ${castleAtta.attachment_id})}">[[${castleAtta.attachment_name}]]</a></li>
					</ul>
				</div>

				<div class="tfr_left" style="display: none;" id="commentContent">
					<div class="zql_Top"></div>
					<div class="zql_Body">
						<dl th:each="castleComment:${castleComments}">
							<dt class="zql_BodyPic">
								<img th:if="${castleComment.comment_user == null}"
									th:src="${castleComment.teacher.img_url}"> <img
									th:if="${castleComment.comment_teacher == null}"
									th:src="${castleComment.user.img_url}">
							</dt>
							<dd class="zql_BodyText">
								<div class="zql_BodyTitle">
									<span th:if="${castleComment.comment_teacher != null}"><span>老师</span>[[${castleComment.teacher.user_name}]]</span>
									<span th:if="${castleComment.comment_user != null}"><span>学员</span>[[${castleComment.user.login_name}]]</span>
									<div style="float: right;" th:id="'editAndDel' + ${castleComment.coment_id}"
										th:if="${session.loginMessage == 'user' && session.sess_user.user_id == castleComment.comment_user}">
										<a class="btn btn-danger"
											th:href="@{/delComment(coment_id=${castleComment.coment_id}, castle_id=${castleComment.castle_id})}">删除</a>
										<a class="btn btn-warning"
											th:onclick="editComment([[${castleComment.coment_id}]])">编辑</a>
									</div>
									<div style="float: right;" th:id="'editAndDel' + ${castleComment.coment_id}"
										th:if="${session.loginMessage == 'teacher' && session.sess_user.teacher_id == castleComment.comment_teacher}">
										<a class="btn btn-danger"
											th:href="@{/delComment(coment_id=${castleComment.coment_id}, castle_id=${castleComment.castle_id})}">删除</a>
										<a class="btn btn-warning"
											th:onclick="editComment([[${castleComment.coment_id}]])">编辑</a>
									</div>
									<div style="float: right; display: none;" th:id="'commit' + ${castleComment.coment_id}">
										<a class="btn btn-warning"
											th:onclick="editCommit([[${castleComment.coment_id}]])">提交</a>
									</div>

								</div>
								<div class="zql_BodyT">
									<form action="editComment" method="post" th:id="'editform_' + ${castleComment.coment_id}">
										<input type="hidden" name="coment_id"
											th:value="${castleComment.coment_id}"> <input
											type="hidden" name="castle_id" th:value="${castle.castle_id}">
										<input type="text" name="coment_desc"
											th:id="'desc_' + ${castleComment.coment_id}"
											th:value="${castleComment.coment_desc}"
											class="zql_BottomTitle" readonly>
									</form>
								</div>
								<div style="width: 170px; float: right;">
									<span>创建日期：</span>[[${#dates.format(castleComment.last_modify,
									'yyyy-MM-dd')}]]
								</div>
							</dd>
						</dl>
					</div>

					<div class="zql_Bottom">
						<form action="addComment1" method="post" id="commentform">
							<input type="hidden" name="castle_id"
								th:value="${castle.castle_id}"> <input type="hidden"
								name="comment_user"
								th:value="${session.loginMessage == 'user'} ? ${session.sess_user.user_id} : null">
							<input type="hidden" name="comment_teacher"
								th:value="${session.loginMessage == 'teacher'} ? ${session.sess_user.teacher_id} : null">
							<div>
								<input name="" type="text" class="zql_BottomTitle" readonly>
							</div>
							<div>
								<textarea name="coment_desc" id="coment_desc" cols="" rows=""
									class="zql_BottomInput"></textarea>
							</div>
							<div class="paddingT20 fn-clear">
								<a href="###" class="zql_BottomButton" onclick="addComment()">发布</a>
							</div>
						</form>
					</div>

				</div>
				<div class="inventDetail">
					<dl>
						<dd style="padding-top: 10px">
							<a href="#"><img th:src="${castle.img_url}"></a>
						</dd>

						<dd style="padding-top: 10px">
							<div class="classInfo_Nr">
								<span>[[${castle.class_title}]]：</span>[[${castle.castle_desc}]]
							</div>
							<div class="fn-clear"></div>
						</dd>
					</dl>
				</div>
			</div>

		</div>
		<div class="ganxingqu">
			<div class="ganxingquH3">您可能感兴趣</div>
			<ul>
				<li style="margin-right: 20px" th:each="castleInfo:${castleInfos}">
					<div class="ganxingquPic">
						<a th:href="@{/toCastleDetail(castle_id=${castleInfo.castle_id})}"><img
							th:src="${castleInfo.img_url}"></a>
					</div>
					<div class="ganxingquText" style="text-align: center">[[${castleInfo.class_title}]]</div>
				</li>
			</ul>
		</div>
	</div>
</body>
</html>
